#include<iostream>
#include<cstring>
using namespace std;
const int N = 25;
char map[N][N];
bool st[N][N];
int n, m;


int dx[] = { -1,0,1,0 };
int dy[] = { 0,1,0,-1 };
int dfs(int x, int y)
{
	int res = 1;
	st[x][y] = 1;
	for (int i = 0; i < 4; i++) {
		int a = x + dx[i];
		int b = y + dy[i];
		if (map[a][b] == '#')continue;
		if (a < 0 || a >= n || b < 0 || b >= m)continue;
		if (st[a][b])continue;
		res += dfs(a, b);
	}
	return res;
}
int main()
{
	while (cin >> m >> n, m || n) {
		memset(st, 0, sizeof(st));
		int x = 0, y = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				cin >> map[i][j];
				if (map[i][j] == '@') {
					x = i;
					y = j;
				}
			}
		}
		cout << dfs(x, y) << endl;
	}
	return 0;
}